package in.indijava.scjp5questions;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class SerializationInHierarchy implements Serializable{

	private static final long serialVersionUID = 9011988540846182903L;

	int k;
	transient int l;
	InnerClass instance1_;
//	transient InnerClass instance1_t;
	InnerClass2 instance2_;
//	transient InnerClass2 instance2_t;
	
	public SerializationInHierarchy() {
		instance1_ = new InnerClass(2);
//		instance1_t = new InnerClass(3);
		instance2_ = new InnerClass2(4);
//		instance2_t = new InnerClass2(5);
		k = 33;
		l = 44;
	}
	
	public static class InnerClass implements Serializable{

		private static final long serialVersionUID = 2078408307581881554L;
		
		private long myvalue = 123123123213L;
		
		public InnerClass(long l) {
			this.myvalue = l;
		}

		@Override
		public String toString() {
			return String.valueOf(this.myvalue);
		}
	}
	
	public static class InnerClass2 extends InnerClass {

		private static final long serialVersionUID = -1686073784850890410L;

		public InnerClass2(long l) {
			super(l);
		}

	}
	
	public static void main(String[] args) {
		try {
			ObjectOutputStream oos = new ObjectOutputStream(System.out);
			oos.writeObject(new SerializationInHierarchy());
			oos.close();
			
		} catch (IOException e) {
			System.err.println("\n\n>"+e.getMessage());
			e.printStackTrace();
		}
	}
	
}
